package app.dev.ems.web.wicket.panel.menu;

import java.io.Serializable;
import java.util.EnumMap;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.model.Model;

import app.dev.ems.web.element.HTMLAttributes;
import app.dev.ems.web.element.NavigationStatus;
import app.dev.ems.web.wicket.panel.BasePanel;

public abstract class BaseMenuPanel extends BasePanel {

	private static final long serialVersionUID = -841589291180665323L;

	private EnumMap<NavigationStatus, Component[]> menuMap;
	
	public BaseMenuPanel(String id) {
		super(id);
		menuMap = new EnumMap<NavigationStatus, Component[]>(NavigationStatus.class);		
	}

	protected void setSelectedLink(NavigationStatus navigationStatus, String cssClassName) {
		Component[] components = menuMap.get(navigationStatus);
		components[0].add(new AttributeAppender(HTMLAttributes.CLASS.getAttribute(), new Model<Serializable>(" " + cssClassName)));
		components[1].add(new AttributeAppender(HTMLAttributes.CLASS.getAttribute(), new Model<Serializable>(" " + cssClassName)));
	}
	
	public EnumMap<NavigationStatus, Component[]> getMenuMap() {
		return menuMap;
	}	
}
